package com.example.intermediate_control;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;

/**
  *
  * @description 单选按钮demo测试
  * @param
  * @return
  * author snjgm
  * time 2022/7/13 下午5:02
  */
public class RadioActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {

    private RadioGroup rdg;
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio);
        tv = findViewById(R.id.tdg_showTV);
        rdg  = findViewById(R.id.rdg);
        rdg.setOnCheckedChangeListener(this);
    }
    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        switch (i){
            case R.id.rdg_one:
                tv.setText("恭喜你，成为了一名男孩");
                break;
            case R.id.rdg_two:
                tv.setText("恭喜你，成为了一名女孩");
                break;
        }
    }
}